<template>
  <base-breadcrumb>
    <a-card
      :bordered="false"
      style="margin-bottom: 50px"
    >
      <a-spin :spinning="spinning">
        <a-tabs default-active-key="1">
          <a-tab-pane
            key="1"
            tab="汇总信息"
          >
            <title-name title="项目信息" />
            <print-button
              :print-content="htmlData"
              :before-print-fn="getLogDoc"
              style="margin-bottom: 20px"
            />
            <a-row :gutter="24">
              <a-col
                      :md="16"
                      :sm="16"
              >
                <a-form-model-item
                        label="所属单位"
                        :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                        :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                >
                  <!--                              v-model="form.branchCompanyName"-->
                  <BaseInput
                          :value='unit'
                          disabled
                  />
                </a-form-model-item>
              </a-col>
<!--              <a-col-->
<!--                :md="8"-->
<!--                :sm="8"-->
<!--              >-->
<!--                <a-form-item-->
<!--                  label="分公司"-->
<!--                  :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"-->
<!--                  :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"-->
<!--                >-->
<!--                  <BaseInput-->
<!--                    v-model="dels.branchCompanyName"-->
<!--                    disabled-->
<!--                  />-->
<!--                </a-form-item>-->
<!--              </a-col>-->
<!--              <a-col-->
<!--                :md="8"-->
<!--                :sm="8"-->
<!--              >-->
<!--                <a-form-item-->
<!--                  label="项目名称"-->
<!--                  :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"-->
<!--                  :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"-->
<!--                >-->
<!--                  <BaseInput-->
<!--                    v-model="dels.projectName"-->
<!--                    disabled-->
<!--                  />-->
<!--                </a-form-item>-->
<!--              </a-col>-->
              <a-col
                :md="8"
                :sm="8"
              >
                <a-form-item
                  label="项目编号"
                  :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                  :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                >
                  <BaseInput
                    v-model="dels.projectNum"
                    disabled
                  />
                </a-form-item>
              </a-col>
            </a-row>
            <a-row :gutter="24">
              <a-col
                :md="8"
                :sm="8"
              >
                <a-form-item
                  label="项目经理"
                  :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                  :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                >
                  <BaseInput
                    v-model="dels.projectManager"
                    disabled
                  />
                </a-form-item>
              </a-col>
              <a-col
                :md="8"
                :sm="8"
              >
                <a-form-item
                  label="日志日期"
                  :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                  :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                >
                  <BaseInput
                    v-model="dels.logDate"
                    disabled
                  />
                </a-form-item>
              </a-col>
              <a-col
                :md="8"
                :sm="8"
              >
                <a-form-item
                  label="上午天气"
                  :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                  :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                >
                  <BaseInput
                    v-model="dels.morningWeatherName"
                    disabled
                  />
                </a-form-item>
              </a-col>
            </a-row>
            <a-row :gutter="24">
              <a-col
                :md="8"
                :sm="8"
              >
                <a-form-item
                  label="下午天气"
                  :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                  :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                >
                  <BaseInput
                    v-model="dels.afterNoonWeatherName"
                    disabled
                  />
                </a-form-item>
              </a-col>
              <a-col
                :md="8"
                :sm="8"
              >
                <a-form-item
                  label="最高温度（˚C）"
                  :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                  :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                >
                  <BaseInput
                    v-model="dels.temperatureMax"
                    disabled
                  />
                </a-form-item>
              </a-col>
              <a-col
                :md="8"
                :sm="8"
              >
                <a-form-item
                  label="最低温度（˚C）"
                  :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                  :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                >
                  <BaseInput
                    v-model="dels.temperatureMin"
                    disabled
                  />
                </a-form-item>
              </a-col>
            </a-row>
            <a-row :gutter="24">
              <a-col
                :md="8"
                :sm="8"
              >
                <a-form-item
                  label="风力"
                  :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                  :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                >
                  <BaseInput
                    v-model="dels.windPower"
                    disabled
                  />
                </a-form-item>
              </a-col>
              <a-col
                :md="8"
                :sm="8"
              >
                <a-form-item
                  label="PM2.5"
                  :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                  :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                >
                  <BaseInput
                    v-model="dels.pm"
                    disabled
                  />
                </a-form-item>
              </a-col>
              <a-col
                :md="8"
                :sm="8"
              >
                <a-form-item
                  label="有无突发事件"
                  :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                  :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                >
                  <BaseInput
                    v-model="dels.whetherEmergencyName"
                    disabled
                  />
                </a-form-item>
              </a-col>
            </a-row>
            <a-row :gutter="24">
              <a-col
                v-if="emergencyInfo"
                :md="24"
                :sm="24"
              >
                <a-form-item
                  label="突发事件说明"
                  :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                  :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                >
                  <BaseInput
                    v-model="dels.emergencyInstructions"
                    type="textarea"
                    disabled
                  />
                </a-form-item>
              </a-col>
            </a-row>
            <!-- <a-row :gutter="24">
              <a-col :md="24" :sm="24">
                <a-form-item
                  label="突发事件说明"
                  :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                  :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                >
                  <BaseInput v-model="dels.emergencyInstructions" type="textarea" disabled />
                </a-form-item>
              </a-col>
            </a-row> -->
            <a-row :gutter="24">
              <a-col
                :md="24"
                :sm="24"
              >
                <a-form-item
                  label="当天主要施工项目"
                  :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                  :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                >
                  <BaseInput
                    v-model="dels.majorConstructionProjects"
                    type="textarea"
                    disabled
                  />
                </a-form-item>
              </a-col>
            </a-row>

            <title-name title="生产情况记录（当日施工项目内容、机械作业、班组工作、生产存在问题）" />
            <div class="second-box">
              <title-name title="基本情况" />
              <div
                style="margin-left: 30px"
                class="mb20"
              >
                <div
                  class="mb12"
                  style="font-size: 14px"
                >出勤人数：</div>
                <s-table
                  ref="table"
                  size="default"
                  bordered
                  row-key="id"
                  :columns="columns"
                  :data="loadData"
                  :show-pagination="false"
                  :scroll="{ y: 600 }"
                >
                  <template slot="footer"> 总人数：{{ total }} </template>
                </s-table>
              </div>
              <a-row :gutter="24">
                <a-col
                  :md="24"
                  :sm="24"
                >
                  <a-form-item
                    class="titleLabel"
                    label="机械、设备使用情况（主要机械情况）"
                    :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                    :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                  >
                    <BaseInput
                      v-model="dels.equipmentUsage"
                      type="textarea"
                      disabled
                    />
                  </a-form-item>
                </a-col>
              </a-row>

              <title-name title="工作内容" />
              <a-row :gutter="24">
                <a-col
                  :md="24"
                  :sm="24"
                >
                  <a-form-item
                    class="titleLabel"
                    label="当天施工内容实际完成情况及主要工程量"
                    :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                    :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                  >
                    <BaseInput
                      v-model="dels.majorWorks"
                      type="textarea"
                      disabled
                    />
                  </a-form-item>
                </a-col>
              </a-row>
              <a-row :gutter="24">
                <a-col
                  :md="24"
                  :sm="24"
                >
                  <a-form-item
                    class="titleLabel"
                    label="使用的主要材料规格、数量（日消耗量）"
                    :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                    :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                  >
                    <BaseInput
                      v-model="dels.materialUsage"
                      type="textarea"
                      disabled
                    />
                  </a-form-item>
                </a-col>
              </a-row>
              <a-row :gutter="24">
                <a-col
                  :md="24"
                  :sm="24"
                >
                  <a-form-item
                    class="titleLabel"
                    label="施工现场有关会议内容（主要简要概述）"
                    :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                    :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                  >
                    <BaseInput
                      v-model="dels.constructionSiteMeetingContent"
                      type="textarea"
                      disabled
                    />
                  </a-form-item>
                </a-col>
              </a-row>
              <a-row :gutter="24">
                <a-col
                  :md="24"
                  :sm="24"
                >
                  <a-form-item
                    label="试块制作情况"
                    :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                    :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                  >
                    <BaseInput
                      v-model="dels.productionOfTestBlock"
                      type="textarea"
                      disabled
                    />
                  </a-form-item>
                </a-col>
              </a-row>
              <a-row :gutter="24">
                <a-col
                  :md="24"
                  :sm="24"
                >
                  <a-form-item
                    class="titleLabel"
                    label="材料进场、送检情况及当日取回试验报告编号及结果"
                    :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                    :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                  >
                    <BaseInput
                      v-model="dels.materialConditions"
                      type="textarea"
                      disabled
                    />
                  </a-form-item>
                </a-col>
              </a-row>

              <title-name title="技术质量安全工作记录（技术质量安全活动、技术质量安全问题、检查验收情况等）" />
              <a-row :gutter="24">
                <a-col
                  :md="24"
                  :sm="24"
                >
                  <a-form-item
                    class="titleLabel"
                    label="建设单位及监理单位对本工程实施工提出的技术、质量、安全、进度要求、意见及采纳实施情况"
                    :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                    :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                  >
                    <BaseInput
                      v-model="dels.implementation"
                      type="textarea"
                      disabled
                    />
                  </a-form-item>
                </a-col>
              </a-row>
              <a-row
                :gutter="24"
                style="margin-top: 15px"
              >
                <a-col
                  :md="24"
                  :sm="24"
                >
                  <a-form-item
                    class="titleLabel"
                    label="往来函件（设计变更、洽商记录、工程联系单等文件编号及内容简要概述）"
                    :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                    :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                  >
                    <BaseInput
                      v-model="dels.currentLetter"
                      type="textarea"
                      disabled
                    />
                  </a-form-item>
                </a-col>
              </a-row>

              <title-name title="检查情况" />
              <a-row :gutter="24">
                <a-col
                  :md="24"
                  :sm="24"
                >
                  <a-form-item
                    class="titleLabel"
                    label="质量自检情况及整改措施"
                    :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                    :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                  >
                    <BaseInput
                      v-model="dels.qualitySelfInspectionAndCorrectiveAction"
                      type="textarea"
                      disabled
                    />
                  </a-form-item>
                </a-col>
              </a-row>
              <a-row :gutter="24">
                <a-col
                  :md="24"
                  :sm="24"
                >
                  <a-form-item
                    class="titleLabel"
                    label="监理单位对相应工程部位的检查结果"
                    :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                    :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                  >
                    <BaseInput
                      v-model="dels.supervisionInspectionResults"
                      type="textarea"
                      disabled
                    />
                  </a-form-item>
                </a-col>
              </a-row>
              <a-row :gutter="24">
                <a-col
                  :md="24"
                  :sm="24"
                >
                  <a-form-item
                    label="安全"
                    :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                    :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                  >
                    <BaseInput
                      v-model="dels.safety"
                      type="textarea"
                      disabled
                    />
                  </a-form-item>
                </a-col>
              </a-row>
              <a-row :gutter="24">
                <a-col
                  :md="24"
                  :sm="24"
                >
                  <a-form-item
                    class="titleLabel"
                    label="监理通知单情况（主要简要概述）"
                    :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                    :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                  >
                    <BaseInput
                      v-model="dels.supervisionNoticeSituation"
                      type="textarea"
                      disabled
                    />
                  </a-form-item>
                </a-col>
              </a-row>
              <a-row :gutter="24">
                <a-col
                  :md="24"
                  :sm="24"
                >
                  <a-form-item
                    class="titleLabel"
                    label="监理安全隐患整改回复情况（主要内容简要概述）"
                    :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                    :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                  >
                    <BaseInput
                      v-model="dels.safetyRiskRectificationNotice"
                      type="textarea"
                      disabled
                    />
                  </a-form-item>
                </a-col>
              </a-row>
              <a-row :gutter="24">
                <a-col
                  :md="24"
                  :sm="24"
                >
                  <a-form-item
                    class="titleLabel"
                    label="安全文明施工、环保等检查情况"
                    :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                    :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                  >
                    <BaseInput
                      v-model="dels.safetyCivilizedConstructionInspection"
                      type="textarea"
                      disabled
                    />
                  </a-form-item>
                </a-col>
              </a-row>
              <a-row :gutter="24">
                <a-col
                  :md="24"
                  :sm="24"
                >
                  <a-form-item
                    class="titleLabel"
                    label="其他情况（如有上级或其他单位的安全质量检查情况）"
                    :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                    :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                  >
                    <BaseInput
                      v-model="dels.otherSituations"
                      type="textarea"
                      disabled
                    />
                  </a-form-item>
                </a-col>
              </a-row>
              <a-row :gutter="24">
                <a-col
                  :md="8"
                  :sm="8"
                >
                  <a-form-item
                    label="填写人"
                    :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                    :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                  >
                    <BaseInput
                      v-model="dels.writtenBy"
                      disabled
                    />
                  </a-form-item>
                </a-col>
                <a-col
                  :md="8"
                  :sm="8"
                >
                  <a-form-item
                    label="填写时间"
                    :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                    :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                  >
                    <BaseInput
                      v-model="dels.writeTime"
                      disabled
                    />
                  </a-form-item>
                </a-col>
              </a-row>

              <title-name title="相关附件信息" />
              <a-form-model-item
                label="当日整体形象航拍照片"
                :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                prop="aerialPhotoFileList"
              >
                <template v-if="dels.aerialPhotoFileList && dels.aerialPhotoFileList.length">
                  <l-table
                    uploadType="image"
                    business-code="PM20"
                    :disabled="true"
                    :upload-arrys.sync="dels.aerialPhotoFileList"
                  ></l-table>
                  <ellipsis
                    tooltip
                    :length="12"
                    class="fileItem"
                    v-for="(item, index) in dels.aerialPhotoFileList"
                    :key="index"
                  >{{ item.name || item.fileName }}</ellipsis>
                </template>
                <span v-else>无</span>
              </a-form-model-item>
              <a-form-model-item
                label="室内代表性部位施工进度照片"
                :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                prop="progressPhotoFileList"
              >
                <template v-if="dels.progressPhotoFileList && dels.progressPhotoFileList.length">
                  <l-table
                    uploadType="image"
                    business-code="PM20"
                    :upload-arrys.sync="dels.progressPhotoFileList"
                    :disabled="true"
                  ></l-table>
                  <ellipsis
                    tooltip
                    :length="12"
                    class="fileItem"
                    v-for="(item, index) in dels.progressPhotoFileList"
                    :key="index"
                  >{{ item.name || item.fileName }}</ellipsis>
                </template>
                <span v-else>无</span>
              </a-form-model-item>
              <a-form-model-item
                label="其他附件"
                :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                prop="fileIds"
              >
                <file-link :file-list="dels.fileArrays"></file-link>
                <!-- <ellipsis tooltip :length="12" class="fileItem" v-for="(item, index) in dels.fileArrays" :key="index">{{
                  item.name || item.fileName
                }}</ellipsis> -->
              </a-form-model-item>

              <title-name
                title="核查"
                style="margin-top: 20px"
              />
              <a-form-model
                ref="form1"
                :model="dels"
                :rules="rules"
              >
              <a-row
                  v-if="isCheck == 1"
                  :gutter="24"
                >
                  <a-col
                    :md="8"
                    :sm="8"
                  >
                  <a-form-model-item 
                      label="施工阶段"
                      :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                      :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                      prop="stageTypeId"
                    >
                    <a-select
                    v-model="dels.stageTypeId"
                    style="width: 100%"
                    placeholder="请选择施工阶段"
                  >
                    <a-select-option
                      v-for="item in types"
                      :key="item.id"
                      :value="item.id"
                    >
                      {{ item.name }}
                    </a-select-option>
                  </a-select>
                    </a-form-model-item>
                  </a-col>
                </a-row>
                <a-row
                  v-if="isCheck == 0"
                  :gutter="24"
                >
                  <a-col
                    :md="8"
                    :sm="8"
                  >
                    <a-form-item
                      label="施工阶段"
                      :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                      :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                    >
                    <a-select
                    v-model="dels.stageTypeId"
                    style="width: 100%"
                    placeholder="请选择施工阶段"
                    disabled
                  >
                    <a-select-option
                      v-for="item in types"
                      :key="item.id"
                      :value="item.id"
                    >
                      {{ item.name }}
                    </a-select-option>
                  </a-select>
                    </a-form-item>
                  </a-col>
                </a-row>
                <a-row
                  v-if="isCheck == 1"
                  :gutter="24"
                >
                  <a-col
                    :md="24"
                    :sm="24"
                  >
                    <a-form-item
                      label="核查备注信息"
                      :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                      :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                    >
                      <BaseTextarea v-model="dels.checkRemarkInformation" />
                    </a-form-item>
                  </a-col>
                </a-row>
                <a-row
                  v-if="isCheck == 0"
                  :gutter="24"
                >
                  <a-col
                    :md="24"
                    :sm="24"
                  >
                    <a-form-item
                      label="核查备注信息"
                      :label-col="{ lg: { span: 7 }, sm: { span: 7 } }"
                      :wrapper-col="{ lg: { span: 17 }, sm: { span: 17 } }"
                    >
                      <BaseTextarea
                        v-model="dels.checkRemarkInformation"
                        disabled
                      />
                    </a-form-item>
                  </a-col>
                </a-row>
              </a-form-model>
            </div>
          </a-tab-pane>
          <a-tab-pane
            key="2"
            tab="日志明细"
          >
            <title-name title="填写人信息" />
            <s-table
              ref="table2"
              size="default"
              bordered
              row-key="id"
              :columns="columnsTwo"
              :data="loadDataTwo"
              :show-pagination="false"
            >
              <span
                :class="{ del_btn: text === '未填写' }"
                slot="fillStatus"
                slot-scope="text"
              > {{ text }} </span>
              <!-- 删除操作 -->
              <a-button
                v-if="record.fillStatus === '已填写'"
                type="link"
                slot="action"
                slot-scope="text, record"
                @click="handleView(record)"
              >查看</a-button>
            </s-table>
          </a-tab-pane>
        </a-tabs>
      </a-spin>
    </a-card>
    <div
      class="page-btn-right-top"
    >
      <a-button
        v-if="$route.query.isCheck == 1"
        :loading="loading"
        type="primary"
        @click="handleReturn"
      >退回</a-button>
      <a-button
        v-if="$route.query.isCheck == 1"
        class="ml12"
        :loading="loading"
        type="primary"
        @click="submit"
      >提交</a-button>
      <a-button
        class="ml12"
        type="primary"
        @click="goBack"
      >关闭</a-button>
    </div>
    <DialogDetail
      ref="dialogDetail"
      :queryParams="params"
    />
    <!-- 退回日志模 -->
    <ReturnedLog
      :id="logId"
      ref="returnedLog"
    />
    <!-- 退回日志模 -->
  </base-breadcrumb>
</template>

<script>
import Vue from 'vue'
import { STable, Ellipsis } from '@/components'
import { getLogCheck, getLogDetails, getLogDoc, getLogDetailByCheck, getLogFiller } from '@/api/project/constructionLog'
import { getTypes } from '@/api/commons'
import printButton from '@/components/BasePrintButton' // 打印
import DialogDetail from './components/DialogDetail' // 日志详情弹窗
import ARow from 'ant-design-vue/es/grid/Row'
import ReturnedLog from './components/ReturnedLog'
import { submitJudgment } from '@/api/subcontractors/standing'
const columns = [
  {
    title: '序号',
    width: 65,
    customRender() {
      return arguments[2] + 1
    }
  },
  {
    title: '分包商',
    dataIndex: 'subcontractorsName'
  },
  {
    title: '分部分项',
    dataIndex: 'partialAllName'
  },
  {
    title: '工种',
    dataIndex: 'jobType.name'
  },
  {
    title: '人数',
    width: 100,
    dataIndex: 'attendanceNumber'
  }
]
const columnsTwo = [
  {
    title: '序号',
    width: 65,
    customRender() {
      return arguments[2] + 1
    }
  },
  {
    title: '部门',
    ellipsis: true,
    dataIndex: 'deptName'
  },
  {
    title: '岗位',
    dataIndex: 'postName'
  },
  {
    title: '姓名',
    dataIndex: 'userName'
  },
  {
    title: '状态',
    dataIndex: 'fillStatus',
    width: 150,
    scopedSlots: { customRender: 'fillStatus' }
  },
  {
    title: '填写时间',
    width: 150,
    dataIndex: 'fillTime'
  },
  {
    title: '操作',
    dataIndex: 'action',
    width: 100,
    scopedSlots: { customRender: 'action' }
  }
]
export default {
  name: 'a' + Date.now(),
  components: {
    ARow,
    printButton,
    STable,
    Ellipsis,
    DialogDetail,
    ReturnedLog
  },
  data() {
    this.columns = columns
    this.columnsTwo = columnsTwo
    return {
      rules: {
        stageTypeId: [{ required: true, message: '请选择施工阶段', trigger: 'change' }],
      },
      unit: '',
      loading: false,
      htmlData: '', // 打印内容
      businessId: '',
      spinning: false,
      data: [],
      form: {},
      loadData: () => {
        return Promise.resolve({
          code: 200,
          data: this.dels.attendanceList || []
        })
      }, // 出勤人数回调
      loadDataTwo: () => {
        // 项目id和日志id存在才请求
        if (this.dels?.projectId && this.logId) {
          return getLogFiller({ id: this.logId, projectId: this.dels.projectId }).then((res) => {
            if (res.code === 200) {
              return res
            }
          })
        }
      }, // 日志明细请求回调
      token: '',
      params: {},
      dels: {},
      logId: '',
      emergencyInfo: false,
      isCheck: null, // 是否是核查
      types:[],
    }
  },
  computed: {
    // 出勤总人数
    total() {
      return this.dels?.attendanceList?.length ? this.dels.attendanceList.map((i) => i?.attendanceNumber)?.reduce((total, pre) => (total || 0) + (pre || 0)) : 0
    }
  },
  created() {
    this.getTypes()
    this.logId = this.$route.query.logId
    this.isCheck = this.$route.query.isCheck
    // this.$multiTab.rename(this.$route.fullPath, this.isCheck ? '核查施工日志' : '查看施工日志')
    this.token = Vue.getAcloudProvider().getAccessToken()
    this.getLogDetails()
  },
  methods: {
    getTypes() {
      getTypes({ type: 46 }).then((res) => {
        this.types = res.data
      })
    },
    /**
     * @description: 查看详情
     * @param {*} e：行对象
     */
    handleView(e) {
      this.params = { id: this.logId, userId: e.userId }
      this.$refs.dialogDetail.visible = true
    },
    // 施工日志打印
    getLogDoc() {
      let that = this
      return new Promise((resolve, reject) => {
        let data = { templateCode: 'CSCEC-SGRZ', businessId: that.logId }
        getLogDoc(data)
          .then((res) => {
            if (res.code == 200 || res.data.code === 200) {
              resolve(res.data.content)
            }
          })
          .catch((e) => {
            that.$message.error(e)
          })
          .finally(() => {
            resolve()
          })
      })
    },
    getCurrentDate() {
      var d1 = new Date()
      var year = d1.getFullYear() //年
      var month = d1.getMonth() + 1 //月
      var day = d1.getDate() //日

      if (month < 10) {
        month = '0' + month
      }
      if (day < 10) {
        day = '0' + day
      }
      this.dels.writeTime = year + '-' + month + '-' + day
    },
    goBack() {
      // 关闭
      this.$multiTab.close()
    },

    getLogDetails() {
      const fn = [getLogDetails, getLogDetailByCheck][this.isCheck]
      this.spinning = true
      fn({ id: this.logId })
        .then((res) => {
          this.spinning = false
          if (res.code === 200) {
            this.dels = res.data
            this.unit = this.dels.branchCompanyName +'/'+ this.dels.projectName
            this.$refs.table.refresh(true)
            if (this.dels.whetherEmergency == 1) {
              this.emergencyInfo = true
            } else {
              this.emergencyInfo = false
            }
          }
        })
        .catch(() => {
          this.spinning = false
        })
    },

    async submit() {
      if (!this.total) {
        this.$message.warning('出勤人数不能为空！')
        return
      }
      this.$refs.form1.validate (async(valid) => {
         if(this.isCheck*1===1 && !valid){
          return false
         }
         this.loading = true
        const res = await submitJudgment({ id: this.logId })
      if (res.code === 200) {
        // 提交
        getLogCheck({
          id: this.logId,
          checkRemarkInformation: this.dels?.checkRemarkInformation,
          stageTypeId: this.dels?.stageTypeId
        })
          .then((res) => {
            this.loading = false
            if (res.code == this.SUCCESS_CODE) {
              this.$message.success('提交成功！')
              this.$router.push({ path: '/project/constructionLog' })
              this.form = {}
            }
          })
          .catch(() => {
            this.loading = false
          })
      } else {
        this.loading = false
        // this.$message.warning('有已退回的日志尚未重新提交，不能核查')
      }
      })
    },
    /**
     * @description: 退回
     * @return {void}
     */
    handleReturn() {
      this.$refs.returnedLog.visible = true
    }
  }
}
</script>

<style>
.fileItem {
  text-align: center;
  display: inline-block;
  width: 104px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 8px;
}
.titleLabel textarea.ant-input {
  max-width: 100%;
  height: auto;
  min-height: 115px;
  line-height: 1.5;
  vertical-align: bottom;
  transition: all 0.3s, height 0s;
}
.second-box .titleName {
  font-size: 14px !important;
  margin-left: 12px;
}
</style>
